#pragma once
///////////////////////////////////////////////////////////////////////////
//																		 //
//	Author:		Michael Mozdzierz										 //
//	Date:		12/06/2014												 //
//	Purpose:	Define a singleton responsable for inilitizeing and 	 //
//				manageing audio in the game								 //
//																		 //
///////////////////////////////////////////////////////////////////////////

#include "../EdgeMath/Vectors.h"
#include <vector>
#include <fmod.h>
#include <fmod_common.h>
#include <fmod.hpp>
#undef PlaySound

using namespace std;

class ISoundElement;

class AudioManager
{
	friend class SoundEffect2D;
	friend class SoundEffect3D;

	
	FMOD::System* fmod_system;

	vector<ISoundElement*> activeElements;

	Vector3 worldListenPosition;



	AudioManager(void);
	~AudioManager(void);
public:
	// play the given sound
	void PlaySound(ISoundElement* sound);
	// stop the given sound
	void StopSound(ISoundElement* sound);
	// pause the give sound
	void PauseSound(ISoundElement* sound);

	// get the master volume for the game
	float getMasterVolume(void) const;

	// get the fmod engine
	FMOD::System* getFMODSystem(void) const { return fmod_system; }

	// get the position all 3D sounds use to ditirmine their world-space volume
	Vector3 getWorldListenPosition(void) const { return worldListenPosition; }

	// set the world-space position to 'listen' for all 3D sounds
	void setWorldListenPosition(Vector3& value) { worldListenPosition = value; }

	// set the master volume for the game
	void setMasterVolume(float value); 

	// Creates a sound with the given format and flags
	SoundEffect2D* CreateSound2D(const char* filename);
	// Creates a sound with the given format and flags
	SoundEffect3D* CreateSound3D(const char* filename);

	// updates audio in the game
	void Update(void);

	static AudioManager* GetInstance(void);
};